package controller;

import java.math.BigInteger;
import java.security.MessageDigest;

public class PasswordEncoder {
	private static final String PRE_SALT = "w1tChD0cToR";
	private static final String POST_SALT = "$uperN0va";

	public String encode(String password) {
		String saltedPassword = PRE_SALT + password + POST_SALT;

		try {
			MessageDigest digester = MessageDigest.getInstance("MD5");
			byte[] digest = digester.digest(saltedPassword.getBytes());

			return new BigInteger(1, digest).toString(16);
		} catch (Exception e) {
			return password;
		}
	}
}
